package com.example.activitysign.controller;

import com.example.activitysign.pages.AjaxResult;
import com.example.activitysign.pages.PageResult;
import com.example.activitysign.pages.PageValidate;
import com.example.activitysign.service.IActivityUserTaskRecordService;
import com.example.activitysign.validate.ActivityUserTaskRecordCreateValidate;
import com.example.activitysign.validate.ActivityUserTaskRecordSearchValidate;
import com.example.activitysign.validate.ActivityUserTaskRecordUpdateValidate;
import com.example.activitysign.vo.activity.ActivityUserTaskRecordListedVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户任务记录管理
 */
@Slf4j
@RestController
@RequestMapping("api/activityUserTaskRecord")
public class ActivityUserTaskRecordController {

    @Resource
    private IActivityUserTaskRecordService iActivityUserTaskRecordService;

    @GetMapping("/list")
    public AjaxResult<PageResult<ActivityUserTaskRecordListedVo>> list(@Validated PageValidate pageValidate,
                                                                       @Validated ActivityUserTaskRecordSearchValidate searchValidate) {
        PageResult<ActivityUserTaskRecordListedVo> list = iActivityUserTaskRecordService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    public AjaxResult<ActivityUserTaskRecordListedVo> detail(@Validated @RequestParam("id") Long id) {
        ActivityUserTaskRecordListedVo detail = iActivityUserTaskRecordService.detail(id);
        return AjaxResult.success(detail);
    }

    /**
     * 用户任务记录新增
     *
     * @param createValidate
     * @return
     */
    @PostMapping("/add")
    public AjaxResult<Object> add(@Validated @RequestBody ActivityUserTaskRecordCreateValidate createValidate) {
        iActivityUserTaskRecordService.add(createValidate);
        return AjaxResult.success();
    }

    /**
     * 用户任务记录编辑
     *
     * @param updateValidate
     * @return
     */
    @PostMapping("/edit")
    public AjaxResult<Object> edit(@Validated @RequestBody ActivityUserTaskRecordUpdateValidate updateValidate) {
        iActivityUserTaskRecordService.edit(updateValidate);
        return AjaxResult.success();
    }


}
